<?php

class Checkbox extends InputField {
	protected $checked;
	
	public function __construct($name, $value = null, $sticky = true)
	{
		if($sticky && isset($_POST[$name]) && isset($_POST[$name][$value]) && $_POST[$name][$value] == 'on')
		{
			$this->setChecked();
		}
		$name = $name .'[' . $value .']';
		parent::__construct('checkbox', $name);
	}
	
	public function setChecked()
	{
		$this->checked = true;
		$this->setExtraAttribute('checked', 'checked');		
	}
	
	public function getChecked()
	{
		return $this->checked;	
	}
}